﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using Microsoft.Practices.Unity;
using System.Windows.Interop;
using Interop;

using ShellAnywhere.ViewModel;
namespace ShellAnywhere.View
{
	/// <summary>
	/// Interaction logic for ShellAnywhereView.xaml
	/// </summary>
	public partial class ShellAnywhereView : Window
	{
		#region ctors
		public ShellAnywhereView() { InitializeComponent(); }
		#endregion ctors

		#region props
		[Dependency]
		public ShellAnywhereViewModel ViewModel
		{
			set 
			{ 
				DataContext = _ViewModel = value;

				SourceInitialized				+= _ViewModel.OnSourceInitialized;
				Closed							+= _ViewModel.OnClosed;

				_ViewModel.ResetColumns = () =>
				{
					GridView gridView = _ActionsListView.View as GridView;
					if (gridView != null)
					{
						foreach (var column in gridView.Columns)
						{
							if (double.IsNaN(column.Width))
								column.Width = column.ActualWidth;
							column.Width = double.NaN;
						}
					}
				};

				//_ViewModel.SetWindowVisibility += OnSetOutputVisibility;
				//_ViewModel.SetOutputVisibility += OnSetWindowVisibility;
			}
		}
		#endregion props

		#region methods
		private void OnSetWindowVisibility(Visibility visibility)
		{
			_ShellAnywhereView.Visibility = visibility;
		}
		//private void OnSetOutputVisibility(Visibility visibility)
		//{
		//    _OutputListView.Visibility = visibility;
		//}
		#endregion methods

		#region events
		#endregion events

		#region fields
		private ShellAnywhereViewModel _ViewModel;
		#endregion fields
	}
}
